package ch14;

public class SimpleThread extends Thread{

	private int countDown = 5;
	
	private int  threadNumber;
	
	private static int threadCount = 0;
	
	public SimpleThread(){
		threadNumber = ++threadCount;
		System.out.println("Making " + threadNumber);
	}
	
	public void run(){
		while(true){
			System.out.println("Thread " + threadNumber 
					+ "(" + countDown + ")");
			
			if(--countDown  == 0) return;
		}
	}
	
	public static void main(String[] args){
	   for(int i=0; i< 5 ; i++){
		   SimpleThread sm = new SimpleThread() ;
		   
		   sm.setPriority(++i);
		   
		   sm.start();
	   }
	   
	   System.out.println("All Threads Started");
	}
	
}
